home *** CD-ROM | disk | FTP | other *** search
- // main file ... from the C.Spathis Shell (ty Gus)
- //
- #define __MAIN__
-
- #include <quickdraw.h>
- #include <drag.h>
- #include <gestaltEqu.h>
- #include "O Boy.h"
- #include "OBoy_hi.h"
-
- Boolean InitMacToolbox(void);
- Boolean InitApplication(void);
-
- #define kMinSize 1
-
- Boolean TrapAvailable(short tNumber,TrapType tType);
- long HeapNeeded(void);
- long StackNeeded(void);
-
-
-
- void main(void)
- {
- Boolean done=FALSE;
-
- if (InitMacToolbox()){
- if (InitApplication()){
- while(!done){
- done=DoEvents();
- }
- }
- }
- ExitApp();
- }
- void ExitApp(void)
- {
-
- }
- Boolean InitMacToolbox(void)
- {
- Boolean ret=TRUE;
- SysEnvRec envRec;
- long stkNeeded, heapSize;
- long response;
-
- // initialize Mac Toolbox components
- InitGraf( &qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
-
- if (Gestalt(gestaltDragMgrAttr, &response) != noErr){
- Draggable=false;
- }else{
- Draggable=true;
- }
-
- // ignore the error returned from SysEnvirons; even if an error occurred,
- // the SysEnvirons glue will fill in the SysEnvRec
- (void) SysEnvirons(curSysEnvVers, &envRec);
-
- // Are we running on a 128K ROM machine or better???
- if (envRec.machineType < 0){
- //BigBadError(kErrStrings,eWrongMachine); // if not, alert & quit
- ret=FALSE;
- }
-
- // if we need more stack space, get it now
- stkNeeded = StackNeeded();
- if (stkNeeded > StackSpace()){
- // new address is heap size + current stack - needed stack
- SetApplLimit((Ptr) ((long) GetApplLimit() - stkNeeded + StackSpace()));
- }
-
- // Check for minimum heap size
- heapSize = (long) GetApplLimit() - (long) ApplicZone();
- if (heapSize < HeapNeeded()){
- //BigBadError(kErrStrings,eSmallSize);
- ret=FALSE;
- }
-
- // expand the heap so new code segments load at the top
- MaxApplZone();
- for (Int16 i = 1; i <= 101; i++) {
- MoreMasters();
- }
-
- bHaveWaitNextEvent = TrapAvailable(_WaitNextEvent, ToolTrap);
-
- return ret;
- }
- Boolean TrapAvailable(short tNumber,TrapType tType)
- {
- // Check and see if the trap exists. On 64K ROM machines, tType will be ignored.
- #ifndef powerc
- return NGetTrapAddress(tNumber, tType) != GetTrapAddress(_Unimplemented);
- #else
- return true;
- #endif
- }
-
- Boolean InitApplication(void)
- {
- Boolean ret=TRUE;
- Handle menuBar;
-
- // read menus into menu bar
- if ((menuBar = GetNewMBar(MAIN_MENU_BAR))!=nil){
- // install menus
- SetMenuBar(menuBar);
- DisposHandle(menuBar);
- // add DA names to Apple menu
- AddResMenu(GetMHandle(APPLE_MENU), 'DRVR');
- DrawMenuBar();
-
- sleepTime=10;
- EventInit();
- gSelfPSN.highLongOfPSN = 0;
- gSelfPSN.lowLongOfPSN = kCurrentProcess; //* Use this instead of GetCurrentProcess *//
- if (AECreateDesc(typeProcessSerialNumber,(Ptr)&gSelfPSN,sizeof(ProcessSerialNumber),&gSelfAddress)!=0){
- return FALSE;
- }
- gNullDesc.descriptorType = typeNull; // Initialize the global null descriptor record.
- gNullDesc.dataHandle = nil;
-
-
- // gestalt check time
- {
- Int_32 theFeature;
- if( Gestalt( gestaltFinderAttr, &theFeature ) == noErr )
- {
- if( (theFeature & (1 << gestaltOSLCompliantFinder ) ) == 0 )
- {
- StopAlert( 130,nil );
- ret = FALSE;
- }
- }
- }
-
- if( ret == TRUE )
- {
- OBoy_hi *theHumanInterface = new OBoy_hi;
- }
- }else{
- ret=FALSE;
- }
- return ret;
- }
- long HeapNeeded(void)
- {
- return (kMinSize * 1024);
- }
- long StackNeeded(void)
- {
- return (kMinSize * 1024);
- }
-
-